/**
 * @param {number[][]} nums
 * @return {number}
 */
var matrixSum = function (nums) {
    let res = 0,len = nums[0].length
    for(let i=0;i<len;i++){
      let max = 0
      for(let j=0;j<nums.length;j++){
       
        max = Math.max(max,...nums[j])
       
        nums[j].splice(nums[j].indexOf(Math.max(...nums[j])),1)
      }
      res+=max
    }

    return res
};

matrixSum([[7,2,1],[6,4,2],[6,5,3],[3,2,1]])